<#import "/layout/mainLayout.html" as mainLayout />

<#macro mainheading>

</#macro>
<#assign mainheading = mainheading in mainLayout />

<#macro maincontent>
    <section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <div class="row">
                        <div class="col-sm-2">
                            <select id="sele_year" name="sele_year" class="form-control" >
                                <option value="2010">2010年</option>
                                <option value="2011">2011年</option>
                                <option value="2012">2012年</option>
                                <option value="2013">2013年</option>
                                <option value="2014">2014年</option>
                                <option value="2015">2015年</option>
                                <option value="2016">2016年</option>
                                <option value="2017">2017年</option>
                            </select>
                        </div>
                        <div class="col-sm-2">

                            <select id="sele_moth" name="sele_moth" class="form-control" >
                                <option value="01">01月</option>
                                <option value="02">02月</option>
                                <option value="03">03月</option>
                                <option value="04">04月</option>
                                <option value="05">05月</option>
                                <option value="06">06月</option>
                                <option value="07">07月</option>
                                <option value="08">08月</option>
                                <option value="09">09月</option>
                                <option value="10">10月</option>
                                <option value="11">11月</option>
                                <option value="12">12月</option>
                            </select>
                        </div>
                        <div class="col-sm-2">
                            <input type="text" class="form-control" id="input_name"
                                   placeholder="用户名称...">
                        </div>
                        <div class="col-sm-1 pull-right">
                            <button class="btn btn-block btn-default " id ="btn_allcount"
                                    onclick="getAllcount()">报表
                            </button>
                        </div>
                        <div class="col-sm-1 pull-right">
                            <button class="btn btn-block btn-default " id ="btn_search" onclick="searchList()">查询
                            </button>


                        </div>

                    </div><!-- /.box-header -->
                </div>

                <div class="box-body table-responsive no-padding">
                    <table class="table table-hover">
                        <tbody>
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>商户AK</th>
                            <th>电影名称</th>
                            <th>商户ip</th>
                            <th>客户ip</th>
                            <th>客户名称</th>
                            <th>获取时间</th>

                        </tr>
                        </thead>
                        <tbody id="bodycontent">


                        </tbody>
                    </table>
                </div><!-- /.box-body -->
                <div id="pagecontent" class="pagination"></div>
            </div><!-- /.box -->
        </div>
    </div>
    </section>
</#macro>
<#assign maincontent = maincontent in mainLayout />

<#macro mainfooter>
    <!--layoutmain footer...-->
    <!--<br />-->
    <script src="/js/jquery/jquery.form.js"></script>

    <script type="text/javascript">

        var data_ak=$.getUrlParam("ak");

        var user_data = {
        };

        function searchList() {


            user_data = {
                year:$('#sele_year').val(),
                moth:$('#sele_moth').val(),
                name:$('#input_name').val(),
                ak:data_ak,
                pno: 1,
                pagesize: 10,
                allcount:-1
            };
            LoadList();
        }
        //加载列表
        //searchList();
        function LoadList() {
            $('#pagecontent').html('');
            $.ajax({
                    url: '/api/merchant/getmerchantloglist',
                    data: user_data,
                    dataType: 'json',
                    success: function (data) {
                        if (mortise_layout.ValidataResult(data)) {
                            if (data.result) {
                                user_data.allcount = data.result.count;
                                var html = '';
                                $.each(data.result.list, function (index, item) {
                                    html += getHtml(item);
                                })
                                $('#bodycontent').html(html);
                                ShowPage('pagecontent', user_data, function (pno) {
                                    user_data.pno = pno;
                                    LoadList();
                                });
                            }
                            else {
                                alert('返回数据错误！');
                            }
                        }
                        else {
                            alert('请求数据失败！');
                        }
                    }
                }
            );
        }
        function  getHtml(dataObject) {

            return ' <tr>'+
                '<td>'+dataObject.id+'</td>'+
                '<td>'+dataObject.ak+'</td>'+
                '<td>'+dataObject.objectId+'</td>'+
                '<td>'+dataObject.serverIp+'</td>'+
                '<td>'+dataObject.ip+'</td>'+
                '<td>'+dataObject.userName+'</td>'+
                '<td>'+dataObject.intime+'</td>'
               ;
        }
        
        
        function getAllcount() {
            $.ajax({
                    url:
                    '/api/merchant/getmerchantlogallcount?ak='+data_ak +
                    '&year='+$('#sele_year').val()+'&moth='+$('#sele_moth').val()+
                    '&name='+$('#input_name').val(),
                    dataType: 'json',
                    success: function (data) {
                        if (mortise_layout.ValidataResult(data)) {
                            if (data.result) {

                                var html = '';
                                $.each(data.result, function (index, item) {

                                    html += '<tr><td>' + item.name + '</td><td>' + item.ct+ '</td>';

                                    html += '</tr>';
                                });

                                if (!$('#minelog_table').html()) {
                                    dialog({
                                        title: '播放统计报表',
                                        content: '  <div class="box-body table-responsive no-padding"><table id="usertable"' +
                                        '  class="table table-bordered table-striped dataTable"><tbody><thead><tr><td>电影名称</td><td>播放次数</td></tr></thead>' +
                                        '<tbody id="minelog_table">' + html + '</tbody></div>',
                                        cancel: true,
                                        cancelValue: '取消'
                                    }).width(640).showModal();
                                } else {
                                    $('#minelog_table').html(html);
                                }
                            }
                            else {
                                alert('返回数据错误！');
                            }
                        }
                        else {
                            alert('请求数据失败！');
                        }
                    }
                }
            );
        }
        
    </script>
</#macro>
<#assign mainfooter = mainfooter in mainLayout />
<@mainLayout.page title="用户管理"/>